package com.ruoyi.wsc.api.factory;

import com.ruoyi.common.core.constant.SecurityConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.wsc.api.RemoteTongJiService;
import com.ruoyi.wsc.api.domain.TongJi;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestHeader;

import java.util.List;

/**
 * 用户服务降级处理
 * 
 * @author ruoyi
 */
@Component
public class RemoteTongJiFallbackFactory implements FallbackFactory<RemoteTongJiService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteTongJiFallbackFactory.class);

    @Override
    public RemoteTongJiService create(Throwable throwable)
    {
        log.error("用户服务调用失败:{}", throwable.getMessage());
        return new RemoteTongJiService()
        {

            @Override
            public AjaxResult tongji(Long id, @RequestHeader(SecurityConstants.FROM_SOURCE) String source) {
                System.out.println("远程调用失败");
                return null;
            }
        };
    }
}
